package com.examples.ry.layouts;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class ForceLayout {

	public static void main(String[] args) {
		Display display = Display.getDefault();
		Shell shell = new Shell(display);
		GridLayout layout = new GridLayout();
		layout.numColumns = 3;
		shell.setLayout(layout);
		for (int i = 0; i < 12; i++) {
			Button button = new Button(shell, SWT.PUSH);
			button.setText("B" + i);
		}
		shell.pack();
		shell.open();
		Button button = (Button) (shell.getChildren()[0]);
		button.setText("B1 is bigger");
		// Force the layout to see the bigger button
		shell.layout(); //Try commenting this line
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}		
	}

}
